/*
 * EditItemType.java
 */

package nxtgeninventorysystem.View.Dialog;

import java.awt.event.ActionEvent;
import java.util.HashMap;
import javax.swing.AbstractAction;
import javax.swing.DefaultComboBoxModel;
import nxtgeninventorysystem.Controller.Actions;
import nxtgeninventorysystem.View.Gui;
import nxtgeninventorysystem.View.Gui.ComboBoxType;

/**
 * The dialog box that displays fields for editing item types.
 * @author Seraph Softworks
 */
public class EditItemType extends GuiDialog {

    /** Creates new form DatabaseConfig */
    public EditItemType(java.awt.Frame parent) {
        super(parent);
    }

    @Override
    public void resetFields() {
        itemTypeNewValue.setText("");
    }

    @Override
    public void refreshComboBoxes(HashMap<ComboBoxType, DefaultComboBoxModel> models) {
        itemTypeOldValue.setModel(models.get(Gui.ComboBoxType.ItemTypesComboBox));
    }

    public void setFields(String old) {
        itemTypeOldValue.setSelectedItem(old);
    }

    @Override
    protected void initialize() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.JButton closeButton = new javax.swing.JButton();
        javax.swing.JButton okButton = new javax.swing.JButton();
        javax.swing.JLabel itemTypeNewLabel = new javax.swing.JLabel();
        itemTypeNewValue = new javax.swing.JTextField();
        itemTypeOldValue = new javax.swing.JComboBox();
        javax.swing.JLabel itemTypeOldLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(nxtgeninventorysystem.Driver.class).getContext().getResourceMap(EditItemType.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setMinimumSize(new java.awt.Dimension(295, 110));
        setName("Form"); // NOI18N
        setResizable(false);

        closeButton.setAction(new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                dispose();
            }
        });
        closeButton.setText(resourceMap.getString("closeButton.text")); // NOI18N
        closeButton.setName("closeButton"); // NOI18N

        okButton.setAction(new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                Actions.item.doUpdateItemType();
            }
        });
        okButton.setText(resourceMap.getString("okButton.text")); // NOI18N
        okButton.setName("okButton"); // NOI18N

        itemTypeNewLabel.setText(resourceMap.getString("itemTypeNewLabel.text")); // NOI18N
        itemTypeNewLabel.setName("itemTypeNewLabel"); // NOI18N

        itemTypeNewValue.setName("itemTypeNewValue"); // NOI18N

        itemTypeOldValue.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "--Select Item Type--" }));
        itemTypeOldValue.setName("itemTypeOldValue"); // NOI18N

        itemTypeOldLabel.setText(resourceMap.getString("itemTypeOldLabel.text")); // NOI18N
        itemTypeOldLabel.setName("itemTypeOldLabel"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(itemTypeNewLabel)
                    .addComponent(itemTypeOldLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(itemTypeOldValue, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(itemTypeNewValue, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(96, 96, 96)
                .addComponent(okButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(closeButton)
                .addContainerGap(89, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(itemTypeOldValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(itemTypeOldLabel))
                .addGap(8, 8, 8)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(itemTypeNewLabel)
                    .addComponent(itemTypeNewValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(closeButton)
                    .addComponent(okButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    protected javax.swing.JTextField itemTypeNewValue;
    protected javax.swing.JComboBox itemTypeOldValue;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the itemTypeNewValue
     */
    public String getItemTypeNew() {
        return itemTypeNewValue.getText();
    }

    /**
     * @return the itemTypeOldValue
     */
    public String getItemTypeOld() {
        return (String) itemTypeOldValue.getSelectedItem();
    }

}
